<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if($_RQ['op']=='edit'){
	$_SESSION['from_pluginname']=$_RQ['from_pluginname']?$_RQ['from_pluginname']:$_SESSION['from_pluginname'];
	$tabs=array(
			array('op'=>'edit','title'=>'小店编辑')
	);
	$item=pdo_get('jy_merch_user',array('uniacid'=>$_SESSION['uniacid'],'pluginname'=>$_SESSION['from_pluginname']));
	$return['item']=$item;
	$htmls=array(
		'type'=>'edit',
		'post'=>'post',
		'desc'=>'小店编辑',
		'edit'=>array(
			array('name'=>'merchname','title'=>'商户名称','type'=>'string'),
			array('name'=>'salecate','title'=>'主营项目','type'=>'string'),								
			array('name'=>'realname','title'=>'联系人','type'=>'string'),
			array('name'=>'mobile','title'=>'联系电话','type'=>'string'),
			array('name'=>'address','title'=>'联系地址','type'=>'string'),
			array('name'=>'lat_lng','title'=>'小店坐标','type'=>'lat_lng'),
			array('name'=>'desc','title'=>'商户简介','type'=>'text'),
		)
	);
	$return['status']=array('0'=>'待审核','1'=>'已审核','2'=>'已驳回');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='post'){
	$postdata=get_postdata();
	if(!$postdata['realname']){
		exi('请填写姓名','error');
	}
	if(!$postdata['mobile']){
		exi('请填写手机号','error');
	}
	if(strlen($postdata['mobile'])!=11){
		exi('请填写正确的手机号','error');
	}
	if(!$postdata['lat_lng']){
		exi('请填写正确的坐标','error');
	}
	$data =array(
		'uniacid'=>$_SESSION['uniacid'],
		'applytime'=>time(),
		'mobile'=>$postdata['mobile'],
		'realname'=>$postdata['realname'],
		'merchname'=>$postdata['merchname'],
		'desc'=>$postdata['desc'],
		'salecate'=>$postdata['salecate'],
		'status'=>1,
		'jointime'=>time(),
		'address'=>$postdata['address'],
		'lat_lng'=>ijson_encode($postdata['lat_lng']),
		'mid'=>$_SESSION['uid']
	);
	pdo_insert('jy_merch_user',$data);
	exi('添加成功');
}